Page({
  data: {
    myCoupons: [],
    ruleOpen: []
  },
  onShow() {
    const myCoupons = wx.getStorageSync('myCoupons') || [];
    this.setData({ myCoupons, ruleOpen: myCoupons.map(() => false) });
  },
  goBack() {
    wx.navigateBack();
  },
  toggleRule(e) {
    const idx = e.currentTarget.dataset.idx;
    const arr = this.data.ruleOpen.slice();
    arr[idx] = !arr[idx];
    this.setData({ ruleOpen: arr });
  },
  copyId(e) {
    wx.setClipboardData({ data: e.currentTarget.dataset.id });
  }
}); 